//Triangle Program - Stevens Institute of Tech.
//Tim Westran - 05/24/2012
//Project 1 - SW567

import java.util.Scanner;
public class Triangle {
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		double Side_1 = 0;
		double Side_2 = 0;
		double Side_3 = 0;
		
		System.out.print("1st side of Triangle? ");
		
		//Let's make sure some joker didn't enter a string here.  Check Side 1
		if (input.hasNextDouble())
		{
			Side_1 = input.nextDouble();
			System.out.print("Side 1:  ");
			System.out.print(Side_1);
		}
		else
		{
			System.out.print("\n you didn't enter a valid side \n");
		}
		
		System.out.print("\n 2nd side of Triangle? ");
		//Input check for Side 2..
		if (input.hasNextDouble())
		{
			Side_2 = input.nextDouble();
			System.out.print("Side 2:  ");
			System.out.print(Side_2);
		}
		else
		{
			System.out.print("\n you didn't enter a valid side \n");
		}
		
		System.out.print("\n 3rd side of Triangle? ");
		//Input check for Side 3..
		if (input.hasNextDouble())
		{
			Side_3 = input.nextDouble();
			System.out.print("Side 3:  ");
			System.out.print(Side_3);
		}
		else
		{
			System.out.print("\n you didn't enter a valid side \n");
		}
		
		//Start the program flow by checking for bad input.
		//If a side is less than 0, then either the user didn't enter a double
		//or the user entered 0 for a side of the triangle
		//or else the user entered a negative number for a side of the triangle.
		//In any of these cases, the sides entered do not make a triangle.
		if ((Side_1 <= 0) || (Side_2 <= 0) || (Side_3 <= 0 ))
		{
			System.out.print("\n \n The numbers entered do NOT make a triangle.  You did not enter a positive number for one (or more) of the sides\n");
		}
		
		//First, lets make sure a triangle was actually entered.
		//If A + B <= C, then the numbers entered can't be a triangle.
		else if ((Side_1 + Side_2) <= (Side_3))
		{
			System.out.print("\n \n The numbers entered do NOT make a triangle.  Please try again. Side 1 or Side 2 is too long, or Side 3 is too short\n");
		}
		//If A + C <= B, then the numbers entered can't be a triangle.
		else if ((Side_1 + Side_3) <= (Side_2))
		{
			System.out.print("\n \n The numbers entered do NOT make a triangle.  Please try again. Side 1 or Side 3 is too long, or Side 2 is too short\n");
		}		
		//If B + C <= A, then the numbers entered can't be a triangle.
		else if ((Side_2 + Side_3) <= (Side_1))
		{
			System.out.print("\n \n The numbers entered do NOT make a triangle.  Please try again. Side 2 or Side 3 is too long, or Side 1 is too short\n");
		}
		
		//If all of the sides are equal, the Triangle is Equilateral.
		else if (Side_1 == Side_2)
		{
			if (Side_2 == Side_3)
			{
				if (Side_1 == Side_3)
				{
					System.out.print("\n \n The triangle you have entered is Equilateral \n");
				}
			}
		}
		
		//This section determines if the triangle is a right triangle.
		//Right Triangle:  A^2 + B^2 = C^2
		else if ((Side_1 * Side_1) + (Side_2 * Side_2) == (Side_3*Side_3))
		{
			System.out.print("\n \n The triangle you have entered is a Right Triangle (Side 1 and Side 2 form the right angle \n");
		}
		//Right Triangle:  B^2 + C^2 = A^2
		else if ((Side_2 * Side_2) + (Side_3 * Side_3) == (Side_1 * Side_1))
		{
			System.out.print("\n \n The triangle you have entered is a Right Triangle (Side 2 and Side 3 form the right angle \n");
		}
		//Right Triangle:  A^2 + C^2 = B^2
		else if ((Side_1 * Side_1) + (Side_3 * Side_3) == (Side_2 * Side_2))
		{
			System.out.print("\n \n The triangle you have entered is a Right Triangle (Side 1 and Side 3 form the right angle \n");
		}
		
		//If we have checked to ensure the numbers entered actually make a triangle and
		// we have checked for equilateral and right triangle, if we get to this point
		// we MUST have a scalene triangle.		
		else
		{
			System.out.print("\n \n The triangle you have entered is a Scalene Triangle \n");
		}
		
	}
}
